home *** CD-ROM | disk | FTP | other *** search
- package sheet;
-
- class Operand {
- private static final byte EMPTY = 0;
- private static final byte TEXT = 1;
- private static final byte NUMBER = 2;
- private static final byte NAME = 3;
- private byte type;
- private String text;
- private int number;
-
- Operand(int var1) {
- this.number = var1;
- this.type = 2;
- this.text = String.valueOf(var1);
- }
-
- Operand(String var1) {
- int var2 = var1.length();
- if (var2 == 0) {
- this.text = "";
- this.type = 0;
- } else if (var1.charAt(0) == '"' && var1.charAt(var2 - 1) == '"') {
- this.text = var1.substring(1, var2 - 1);
- this.type = 1;
- } else {
- this.text = var1;
-
- try {
- this.number = Integer.parseInt(this.text);
- this.type = 2;
- } catch (NumberFormatException var4) {
- this.type = 3;
- }
- }
-
- }
-
- Operand(String var1, boolean var2) {
- if (var1.length() == 0) {
- this.text = var1;
- this.type = 0;
- } else {
- this.text = var1;
- if (var2) {
- try {
- this.number = Integer.parseInt(this.text);
- this.type = 2;
- } catch (NumberFormatException var4) {
- this.type = 1;
- }
- } else {
- this.type = 1;
- }
- }
-
- }
-
- static final boolean isNumber(Operand var0) {
- return var0 == null || var0.type == 0 || var0.type == 2;
- }
-
- static final boolean isName(Operand var0) {
- return var0 != null && var0.type == 3;
- }
-
- static final int getNumber(Operand var0) throws NumberFormatException {
- if (var0 == null) {
- return 0;
- } else {
- switch (var0.type) {
- case 0:
- return 0;
- case 2:
- return var0.number;
- default:
- throw new NumberFormatException("Not a number: '" + var0.text + "'");
- }
- }
- }
-
- static final String getText(Operand var0) throws NumberFormatException {
- if (var0 == null) {
- return "";
- } else if (var0.type != 3) {
- return var0.text;
- } else {
- throw new NumberFormatException("Not a text: '" + var0.text + "'");
- }
- }
-
- static final String getName(Operand var0) throws NumberFormatException {
- if (var0 == null) {
- throw new NumberFormatException("No data");
- } else if (var0.type == 3) {
- return var0.text;
- } else {
- throw new NumberFormatException("Not a name: '" + var0.text + "'");
- }
- }
- }
-